package cwb1;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * This class represents a subdivision. 
 * 
 * Hierarchy clarification:
 * Engineering science = department
 * Major computer science, minor electrical engineering (2 Bachelor) = division
 * (BIR-)CWELEC-B1 = subdivision
 * 
 * 
 * @author Aurora
 *
 */
public class Subdivision extends Division
{
	//the amount of fields passed to the database.
	private static final int AMOUNT_OF_IMPORTANT_FIELDS = 2;
	// The name of the subdivision
	private String subdivisionName;
	// The date of expire of the subdivision
	private Date expireDate;
	
	/**
	 * This method makes a subdivision object.
	 * 
	 * @param departmentPrefix The prefix referring to the department.
	 * @param division The division.
	 * @param subdivisionSuffix The suffix referring to the subgroups of the division.
	 * @param expireDate
	 */
    public Subdivision(String departmentPrefix, String division, String subdivisionSuffix, Date expireDate)
    {
    	super(departmentPrefix + "-" + division + "-" + subdivisionSuffix, DivisionFactory.SUBDIVISION);
    	this.subdivisionName = departmentPrefix + "-" + division + "-" + subdivisionSuffix;
    	this.expireDate = expireDate;
    }
    
    public Subdivision(Map<String,Object> properties) {
    	super(properties);
    	subdivisionName = (String) properties.get("subdivisionName");
    	expireDate = (Date) properties.get(expireDate);
    }
    
    public HashMap<String, Object> getProperties() {
    	HashMap<String, Object> properties = super.getProperties();
    	properties.put("subdivisionName", subdivisionName);
    	properties.put("expireDate", expireDate);
    	
    	return properties;
    }
    
    /**
     * This method returns the name of the subdivision.
     * 
     * @return The name of the subdivision.
     */
    public String getSubdivisionName()
    {
    	return subdivisionName;
    }
    
    /**
     * This method returns the date of expire of the subdivision.
     * 
     * @return The date of expire of the subdivision.
     */
    public Date getExpireDate()
    {
    	return expireDate;
    }

	@Override
	public int getAmountOfFields() {
		return AMOUNT_OF_IMPORTANT_FIELDS;
	}

}
